/*
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved.
 */
package com.hbisdt.cet.sample.mapper;

import com.hbisdt.cet.sample.entity.dto.CarbonArticleRequest;
import com.hbisdt.cet.sample.entity.po.CarbonArticle;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 碳业务文章表 Mapper 接口
 *
 * @author : 教学示例
 * @version : 1.0
 * @date : 2024-12-10 11:50
 */
@Mapper
public interface CarbonArticleMapper {

//    @Insert("INSERT INTO carbon_article " +
//            "(title, description, content, publish, del_flag, create_user, create_time, update_user, update_time) " +
//            "VALUES (#{title}, #{description}, #{content}, #{publish}, #{delFlag}, #{createUser}, #{createTime}, #{updateUser}, #{updateTime})")
    Long insert(CarbonArticle carbonArticle);

//    @Update("UPDATE carbon_article SET " +
//            "title = #{title}, " +
//            "description = #{description}, " +
//            "content = #{content}, " +
//            "publish = #{publish}, " +
//            "del_flag = #{delFlag}, " +
//            "update_user = #{updateUser}, " +
//            "update_time = #{updateTime} " +
//            "WHERE article_id = #{articleId}")
    Long updateById(CarbonArticle carbonArticle);

//    @Delete("DELETE FROM carbon_article WHERE article_id = #{articleId}")
    Long deleteById(Long articleId);

//    @Select("SELECT * FROM carbon_article WHERE article_id=#{articleId}")
    CarbonArticle selectById(Long articleId);

//    @Select("SELECT * FROM carbon_article " +
//            "WHERE del_flag = 0 " +
//            "AND title LIKE CONCAT('%', #{title}, '%') " +
//            "AND publish = #{publish}")
    List<CarbonArticle> selectAll(CarbonArticleRequest request);
}
